<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>店铺修改</title>
    <link rel="stylesheet" href="css/base.css" />
    <link rel="stylesheet" href="css/all.css" />
    <link rel="stylesheet" href="css/iconfont.css" />
    <link rel="stylesheet" href="css/enterprise-certification.css" />
</head>
<body>
<div>
    <div class="head">
         <span href="javascript:;" onclick="go()">
        <i class="iconfont icon-iconfontjiantou1"></i></span>
        <h1 class="titles">创建店铺</h1>
        <a onclick="createStore()">
            <span class="achieve">完成</span>
        </a>
    </div>
    <div class="middles">
        <div class="name">
            <span>店名：</span>
            <input type="text" placeholder="请输入店铺名称，建议少于12个字" class="resetUpwd-inputs" id="storeName"/>
        </div>
        <div class="names">
            <p>*简单易懂、朗朗上口，尽量体现主营商品，不适用国家法律禁止的违规词，不要出现“淘宝、微信、代理”等会被屏蔽词汇。</p>
        </div>
        <div onclick="location.href='./head.html'" class="photo row">
            <div class="photo-one">
                <span>店铺logo:</span>
            </div>
            <div class="photos">
                <img src="" alt="" id="storeImg">
            </div>
            <div class="photo-one">
                <i class="iconfont icon-youjiantou"></i>
            </div>
        </div>
        <div class="names">
            <p>*尽量与商家/商品一致的LOGO形象，让用户更容易识别。</p>
        </div>
        <div>
            <p class="store">店铺简介：</p>
            <textarea class="describe" placeholder="请给自己的店铺写一段介绍" id="storeIntro"></textarea>
        </div>
    </div>
</div>
<script src="js/x_rem.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/all.js"></script>
<script src="js/url.js" type="text/javascript" charset="utf-8"></script>
<script src="js/layer/layer.js"></script>
<script>
    $(function () {
        var userId = GetQueryString("userId");
        var token = GetQueryString("token");
        if(userId!=null&&token!=null) {
            localStorage.setItem("userId", userId);
            localStorage.setItem("token", token);
        }
    });

    function createStore() {
        var userId=localStorage.getItem("userId");
        var token=localStorage.getItem("token");
        var name= $(".resetUpwd-inputs").val();
        var introduce=$(".describe").val();
        $.ajax({
            type : "POST",
            url : "app/store/register",
            contentType: "application/json;charset=utf-8",
            data: JSON.stringify({
                "introduce": introduce,
                "name": name,
            }),
            dataType: "json",
            beforeSend: function (XMLHttpRequest) {
                XMLHttpRequest.setRequestHeader("token", token);
                XMLHttpRequest.setRequestHeader("userId", userId);
            },
            error : function(request) {
                alert("Connection error ");
            },
            success : function(data) {
                layer.msg(data.message.msg);
                location.href='./shop-page.html'
            }
        });
    }
</script>
</body>
</html>